package com.all.play.myapplication.view;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.all.play.myapplication.R;

/**
 * Created by 聪明一只哈 on 2018/3/28.
 */

public class TitleBarView extends LinearLayout implements View.OnClickListener{

    View tv_search;
    View rl_game;
    View im_history;
    private Context context;

    public TitleBarView(Context context) {
        this(context,null);
    }

    public TitleBarView(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs,0);
    }

    public TitleBarView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.context=context;
    }


    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        tv_search=getChildAt(1);
        rl_game=getChildAt(2);
        im_history=getChildAt(3);

        tv_search.setOnClickListener(this);
        rl_game.setOnClickListener(this);
        im_history.setOnClickListener(this);


    }

    @Override
    public void onClick(View v) {
        switch(v.getId()){
            case R.id.tv_search:
                Toast.makeText(context, "搜索内容", Toast.LENGTH_SHORT).show();
                break;
            case R.id.rl_game:
                Toast.makeText(context, "添加游戏", Toast.LENGTH_SHORT).show();
                break;
            case R.id.im_history:
                Toast.makeText(context, "历史记录", Toast.LENGTH_SHORT).show();
                break;

            default:

                break;
        }
    }
}
